package com.thekernel.youdaoyun.service.impl;

import com.thekernel.youdaoyun.bean.Feedback;
import com.thekernel.youdaoyun.exception.MyException;
import com.thekernel.youdaoyun.mapper.FeedbackMapper;
import com.thekernel.youdaoyun.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @Author: thekernel
 * @Date: 2020/3/25 22:06
 * @Version: 1.0
 * @Description:
 */
@Service("FeedbackService")
public class FeedbackServiceImpl implements FeedbackService {

    @Autowired
    private FeedbackMapper feedbackMapper;


    @Override
    public int addFeedback(Feedback feedback) throws MyException {
        if (feedback.getUserId() == 0 || feedback.getContent().equals("")) {
            return -1;
        }
        if (feedback.getType() == null) {
            feedback.setType(0);
        }
        feedback.setStatus(Boolean.TRUE);
        feedback.setCreateTime(new Date());
        return this.feedbackMapper.add(feedback);
    }
}
